<template>
    <div class="user-manage">
        <el-card class="box-card main-card">
            <template #header>
                <div class="card-header">
                    <span class="card-title">系统用户管理</span>
                    <el-button type="primary" plain :icon="Refresh" circle @click="getList"
                        class="refresh-btn"></el-button>
                </div>
            </template>

            <div class="filter-container">
                <el-form :inline="true" :model="queryParams" class="search-form">
                    <el-form-item label="用户ID">
                        <el-input v-model="queryParams.uid" placeholder="用户ID" clearable
                            prefix-icon="Search"></el-input>
                    </el-form-item>
                    <el-form-item label="用户名">
                        <el-input v-model="queryParams.username" placeholder="用户名" clearable
                            prefix-icon="User"></el-input>
                    </el-form-item>
                    <el-form-item label="昵称">
                        <el-input v-model="queryParams.nickname" placeholder="昵称" clearable
                            prefix-icon="UserFilled"></el-input>
                    </el-form-item>
                    <el-form-item label="角色">
                        <el-select v-model="queryParams.role" placeholder="角色" clearable>
                            <el-option v-for="item in roleOptions" :key="item.value" :label="item.label"
                                :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="状态">
                        <el-select v-model="queryParams.state" placeholder="状态" clearable>
                            <el-option v-for="item in stateOptions" :key="item.value" :label="item.label"
                                :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item class="action-item">
                        <el-button type="primary" :icon="Search" @click="handleQuery" class="query-btn">查询</el-button>
                        <el-button :icon="Refresh" @click="resetQuery" class="reset-btn">重置</el-button>
                    </el-form-item>
                </el-form>
            </div>

            <el-table v-loading="loading" :data="userList" border stripe highlight-current-row style="width: 100%"
                row-key="uid" class="user-table">
                <el-table-column prop="uid" label="ID" width="80" align="center"></el-table-column>
                <el-table-column prop="username" label="用户名" width="120"></el-table-column>
                <el-table-column prop="nickname" label="昵称" width="120"></el-table-column>
                <el-table-column label="头像" width="80" align="center">
                    <template #default="scope">
                        <el-avatar :size="50" :src="scope.row.avatar || defaultAvatar" class="user-avatar"
                            @click="previewAvatar(scope.row)"></el-avatar>
                    </template>
                </el-table-column>
                <el-table-column prop="description" label="个性签名" show-overflow-tooltip></el-table-column>
                <el-table-column prop="role" label="角色" width="130">
                    <template #default="scope">
                        <el-tag :type="scope.row.role === 0 ? 'info' : scope.row.role === 1 ? 'success' : 'danger'"
                            effect="light" class="role-tag">
                            <el-icon class="tag-icon">
                                <UserFilled />
                            </el-icon>
                            {{ formatRole(scope.row.role) }}
                        </el-tag>
                    </template>
                </el-table-column>
                <el-table-column prop="state" label="状态" width="100">
                    <template #default="scope">
                        <el-tag :type="scope.row.state === 0 ? 'success' : scope.row.state === 1 ? 'danger' : 'info'"
                            effect="light" class="state-tag">
                            <el-icon class="tag-icon">
                                <component
                                    :is="scope.row.state === 0 ? 'Check' : scope.row.state === 1 ? 'CloseBold' : 'InfoFilled'" />
                            </el-icon>
                            {{ formatState(scope.row.state) }}
                        </el-tag>
                    </template>
                </el-table-column>
                <el-table-column prop="create_date" label="注册时间" width="180">
                    <template #default="scope">
                        <el-tooltip :content="formatFullTime(scope.row.create_date)" placement="top" :show-after="500">
                            <div class="time-cell">
                                <el-icon>
                                    <Calendar />
                                </el-icon>
                                <span>{{ formatTime(scope.row.create_date) }}</span>
                            </div>
                        </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column label="操作" fixed="right" width="280" align="center">
                    <template #default="scope">
                        <div class="action-buttons">
                            <el-tooltip content="编辑用户" placement="top" :show-after="500">
                                <el-button type="primary" size="small" :icon="Edit" @click="handleEdit(scope.row)"
                                    class="action-btn">
                                    编辑
                                </el-button>
                            </el-tooltip>

                            <el-tooltip :content="scope.row.state === 0 ? '封禁用户' : '解封用户'" placement="top"
                                :show-after="500">
                                <el-button :type="scope.row.state === 0 ? 'danger' : 'success'" size="small"
                                    :icon="scope.row.state === 0 ? Lock : Unlock" @click="handleStateChange(scope.row)"
                                    v-if="scope.row.state !== 2" class="action-btn">
                                    {{ scope.row.state === 0 ? '封禁' : '解封' }}
                                </el-button>
                            </el-tooltip>

                            <el-tooltip content="修改角色" placement="top" :show-after="500">
                                <el-button type="warning" size="small" :icon="UserFilled"
                                    @click="handleRoleChange(scope.row)" class="action-btn">
                                    角色
                                </el-button>
                            </el-tooltip>

                            <el-tooltip content="重置密码" placement="top" :show-after="500">
                                <el-button type="info" size="small" :icon="Key" @click="handleResetPwd(scope.row)"
                                    class="action-btn">
                                    重置密码
                                </el-button>
                            </el-tooltip>
                        </div>
                    </template>
                </el-table-column>
            </el-table>

            <div class="pagination-container">
                <el-pagination background layout="total, sizes, prev, pager, next, jumper" :total="total"
                    v-model:current-page="queryParams.pageNum" v-model:page-size="queryParams.pageSize"
                    @size-change="handleSizeChange" @current-change="handleCurrentChange"></el-pagination>
            </div>
        </el-card>

        <!-- 编辑用户对话框 -->
        <el-dialog v-model="editDialogVisible" title="编辑用户信息" width="550px" :close-on-click-modal="false"
            destroy-on-close class="custom-dialog">
            <div class="dialog-content">
                <el-avatar :size="80" :src="editForm.avatar || defaultAvatar" class="dialog-avatar"></el-avatar>

                <el-form :model="editForm" :rules="rules" ref="editFormRef" label-width="100px" class="dialog-form">
                    <el-form-item label="用户ID">
                        <el-input v-model="editForm.uid" disabled class="custom-input"></el-input>
                    </el-form-item>
                    <el-form-item label="用户名">
                        <el-input v-model="editForm.username" disabled class="custom-input"></el-input>
                    </el-form-item>
                    <el-form-item label="昵称" prop="nickname">
                        <el-input v-model="editForm.nickname" class="custom-input"></el-input>
                    </el-form-item>
                    <el-form-item label="性别">
                        <el-select v-model="editForm.gender" class="full-width custom-select">
                            <el-option label="女" :value="0"></el-option>
                            <el-option label="男" :value="1"></el-option>
                            <el-option label="保密" :value="2"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="个性签名">
                        <el-input v-model="editForm.description" type="textarea" :rows="3"
                            class="custom-textarea"></el-input>
                    </el-form-item>
                    <el-form-item label="认证类型">
                        <el-select v-model="editForm.auth" class="full-width custom-select">
                            <el-option label="普通用户" :value="0"></el-option>
                            <el-option label="个人认证" :value="1"></el-option>
                            <el-option label="机构认证" :value="2"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="认证信息">
                        <el-input v-model="editForm.authMsg" class="custom-input"></el-input>
                    </el-form-item>
                </el-form>
            </div>
            <template #footer>
                <div class="dialog-footer">
                    <el-button @click="editDialogVisible = false" plain>取消</el-button>
                    <el-button type="primary" @click="submitEdit" :loading="submitLoading">保存</el-button>
                </div>
            </template>
        </el-dialog>

        <!-- 更改角色对话框 -->
        <el-dialog v-model="roleDialogVisible" title="更改用户角色" width="450px" :close-on-click-modal="false"
            destroy-on-close class="custom-dialog">
            <div class="role-dialog-content">
                <div class="user-info">
                    <el-avatar :size="60" :src="roleForm.avatar || defaultAvatar" class="role-avatar"></el-avatar>
                    <div class="user-details">
                        <div class="username">{{ roleForm.username }}</div>
                        <div class="nickname">{{ roleForm.nickname }}</div>
                    </div>
                </div>

                <el-form :model="roleForm" ref="roleFormRef" label-width="100px" class="dialog-form">
                    <el-form-item label="当前角色">
                        <el-tag
                            :type="roleForm.currentRole === 0 ? 'info' : roleForm.currentRole === 1 ? 'success' : 'danger'"
                            effect="dark" class="role-dialog-tag">
                            <el-icon>
                                <UserFilled />
                            </el-icon>
                            {{ formatRole(roleForm.currentRole) }}
                        </el-tag>
                    </el-form-item>
                    <el-form-item label="新角色" prop="newRole">
                        <el-select v-model="roleForm.newRole" class="full-width custom-select">
                            <el-option label="普通用户" :value="0">
                                <div class="role-option">
                                    <el-icon>
                                        <User />
                                    </el-icon>
                                    <span>普通用户</span>
                                </div>
                            </el-option>
                            <el-option label="管理员" :value="1">
                                <div class="role-option">
                                    <el-icon>
                                        <Avatar />
                                    </el-icon>
                                    <span>管理员</span>
                                </div>
                            </el-option>
                            <el-option label="超级管理员" :value="2">
                                <div class="role-option">
                                    <el-icon>
                                        <Star />
                                    </el-icon>
                                    <span>超级管理员</span>
                                </div>
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-form>
            </div>
            <template #footer>
                <div class="dialog-footer">
                    <el-button @click="roleDialogVisible = false" plain>取消</el-button>
                    <el-button type="primary" @click="submitRoleChange" :loading="submitLoading">确认更改</el-button>
                </div>
            </template>
        </el-dialog>

        <!-- 头像预览对话框 -->
        <el-dialog v-model="avatarPreviewVisible" width="400px" :close-on-click-modal="true" center
            class="avatar-preview-dialog">
            <div class="avatar-preview-content">
                <img :src="previewUser.avatar || defaultAvatar" class="preview-image" />
                <h3 class="preview-title">{{ previewUser.nickname }}</h3>
                <div class="preview-info">
                    <p><el-icon>
                            <User />
                        </el-icon> 用户名: {{ previewUser.username }}</p>
                    <p><el-icon>
                            <InfoFilled />
                        </el-icon> 角色: {{ formatRole(previewUser.role) }}</p>
                    <p><el-icon>
                            <Calendar />
                        </el-icon> 注册时间: {{ formatFullTime(previewUser.create_date) }}</p>
                </div>
                <div class="preview-description" v-if="previewUser.description">
                    <p><el-icon>
                            <ChatLineRound />
                        </el-icon> {{ previewUser.description }}</p>
                </div>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import {
    Search, Refresh, Edit, Lock, Unlock, UserFilled, Key, User,
    Calendar, InfoFilled, ChatLineRound, Check, CloseBold, Star, Avatar
} from '@element-plus/icons-vue';

export default {
    name: "UserManage",
    data() {
        return {
            // 图标
            Search,
            Refresh,
            Edit,
            Lock,
            Unlock,
            UserFilled,
            Key,
            User,
            Calendar,
            InfoFilled,
            ChatLineRound,
            Check,
            CloseBold,
            Star,
            Avatar,
            // 默认头像
            defaultAvatar: 'https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png',
            // 查询参数
            queryParams: {
                uid: undefined,
                username: undefined,
                nickname: undefined,
                role: undefined,
                state: undefined,
                pageNum: 1,
                pageSize: 10
            },
            // 角色选项
            roleOptions: [
                { value: 0, label: '普通用户' },
                { value: 1, label: '管理员' },
                { value: 2, label: '超级管理员' }
            ],
            // 状态选项
            stateOptions: [
                { value: 0, label: '正常' },
                { value: 1, label: '封禁' },
                { value: 2, label: '已注销' }
            ],
            // 用户列表
            userList: [],
            // 总条数
            total: 0,
            // 加载状态
            loading: false,
            submitLoading: false,
            // 编辑对话框
            editDialogVisible: false,
            // 编辑表单
            editForm: {
                uid: undefined,
                username: '',
                nickname: '',
                gender: 2,
                description: '',
                auth: 0,
                authMsg: '',
                avatar: ''
            },
            // 表单验证规则
            rules: {
                nickname: [
                    { required: true, message: '请输入昵称', trigger: 'blur' },
                    { min: 2, max: 32, message: '昵称长度在 2 到 32 个字符', trigger: 'blur' }
                ]
            },
            // 角色对话框
            roleDialogVisible: false,
            // 角色表单
            roleForm: {
                uid: undefined,
                currentRole: 0,
                newRole: 0,
                username: '',
                nickname: '',
                avatar: ''
            },
            // 头像预览
            avatarPreviewVisible: false,
            previewUser: {}
        };
    },
    created() {
        this.getList();
    },
    methods: {
        // 获取用户列表
        async getList() {
            this.loading = true;
            try {
                const response = await this.$post('/admin/user/list', this.queryParams);
                if (response.data.code === 200) {
                    this.userList = response.data.data.list.map(user => {
                        return {
                            ...user,
                            create_date: user.createDate || user.create_date
                        };
                    });
                    // this.total = response.data.data.total;
                    this.total = response.data.data.total || this.userList.length;
                } else {
                    this.$message.error(response.data.message || '获取用户列表失败');
                }
            } catch (error) {
                console.error('获取用户列表失败', error);
                this.$message.error('获取用户列表失败');
            } finally {
                this.loading = false;
            }
        },
        // 查询
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        // 重置查询
        resetQuery() {
            this.queryParams = {
                uid: undefined,
                username: undefined,
                nickname: undefined,
                role: undefined,
                state: undefined,
                pageNum: 1,
                pageSize: 10
            };
            this.getList();
        },
        // 每页条数改变
        handleSizeChange(val) {
            this.queryParams.pageSize = val;
            this.getList();
        },
        // 当前页改变
        handleCurrentChange(val) {
            this.queryParams.pageNum = val;
            this.getList();
        },
        // 编辑用户
        handleEdit(row) {
            this.editForm = {
                uid: row.uid,
                username: row.username,
                nickname: row.nickname,
                gender: row.gender,
                description: row.description,
                auth: row.auth,
                authMsg: row.authMsg || '',
                avatar: row.avatar
            };
            this.editDialogVisible = true;
        },
        // 提交编辑
        async submitEdit() {
            this.submitLoading = true;
            try {
                const response = await this.$post('/admin/user/update', this.editForm);
                if (response.data.code === 200) {
                    this.$message.success('更新用户信息成功');
                    this.editDialogVisible = false;
                    this.getList();
                } else {
                    this.$message.error(response.data.message || '更新用户信息失败');
                }
            } catch (error) {
                console.error('更新用户信息失败', error);
                this.$message.error('更新用户信息失败');
            } finally {
                this.submitLoading = false;
            }
        },
        // 改变用户状态
        handleStateChange(row) {
            const isActive = row.state === 0;
            const action = isActive ? '封禁' : '解封';
            const newState = isActive ? 1 : 0;

            this.$confirm(`确定要${action}用户 ${row.nickname} 吗？`, '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(async () => {
                try {
                    const response = await this.$post('/admin/user/updateState', {
                        uid: row.uid,
                        state: newState
                    });
                    if (response.data.code === 200) {
                        this.$message.success(`${action}用户成功`);
                        this.getList();
                    } else {
                        this.$message.error(response.data.message || `${action}用户失败`);
                    }
                } catch (error) {
                    console.error(`${action}用户失败`, error);
                    this.$message.error(`${action}用户失败`);
                }
            }).catch(() => {
                // 取消操作，不做处理
            });
        },
        // 重置密码
        handleResetPwd(row) {
            this.$confirm(`确定要重置 ${row.nickname} 的密码吗？`, '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(async () => {
                try {
                    const response = await this.$post('/admin/user/resetPassword', {
                        uid: row.uid
                    });
                    if (response.data.code === 200) {
                        this.$message.success(response.data.message || '重置密码成功');
                    } else {
                        this.$message.error(response.data.message || '重置密码失败');
                    }
                } catch (error) {
                    console.error('重置密码失败', error);
                    this.$message.error('重置密码失败');
                }
            }).catch(() => {
                // 取消操作，不做处理
            });
        },
        // 角色修改
        handleRoleChange(row) {
            this.roleForm = {
                uid: row.uid,
                currentRole: row.role,
                newRole: row.role,
                username: row.username,
                nickname: row.nickname,
                avatar: row.avatar
            };
            this.roleDialogVisible = true;
        },
        // 提交角色修改
        async submitRoleChange() {
            if (this.roleForm.currentRole === this.roleForm.newRole) {
                this.$message.info('角色未发生变化');
                this.roleDialogVisible = false;
                return;
            }

            this.submitLoading = true;
            try {
                const response = await this.$post('/admin/user/updateRole', {
                    uid: this.roleForm.uid,
                    role: this.roleForm.newRole
                });
                if (response.data.code === 200) {
                    this.$message.success('更新用户角色成功');
                    this.roleDialogVisible = false;
                    this.getList();
                } else {
                    this.$message.error(response.data.message || '更新用户角色失败');
                }
            } catch (error) {
                console.error('更新用户角色失败', error);
                this.$message.error('更新用户角色失败');
            } finally {
                this.submitLoading = false;
            }
        },
        // 头像预览
        previewAvatar(user) {
            this.previewUser = { ...user };
            this.avatarPreviewVisible = true;
        },
        // 格式化角色
        formatRole(role) {
            const roles = {
                0: '普通用户',
                1: '管理员',
                2: '超级管理员'
            };
            return roles[role] || '未知';
        },
        // 格式化状态
        formatState(state) {
            const states = {
                0: '正常',
                1: '封禁',
                2: '已注销'
            };
            return states[state] || '未知';
        },
        // 格式化为友好显示
        formatTime(timestamp) {
            if (!timestamp) return '暂无数据';

            // 支持ISO格式时间字符串和createDate字段
            const date = new Date(timestamp);
            if (isNaN(date.getTime())) return '时间格式错误';

            return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
        },
        // 格式化完整时间(带时分秒)
        formatFullTime(timestamp) {
            if (!timestamp) return '暂无数据';

            const date = new Date(timestamp);
            if (isNaN(date.getTime())) return '时间格式错误';

            return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}:${String(date.getSeconds()).padStart(2, '0')}`;
        }
    }
};
</script>

<style scoped>
.user-manage {
    padding: 20px;
    background-color: #f5f7fa;
    min-height: calc(100vh - 60px);
}

.main-card {
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
    transition: all 0.4s ease-in-out;
}

.main-card:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #f0f2f5;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: #303133;
    position: relative;
    padding-left: 12px;
}

.card-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 18px;
    background: #409EFF;
    border-radius: 2px;
}

.refresh-btn {
    transition: all 0.3s;
}

.refresh-btn:hover {
    transform: rotate(180deg);
}

.filter-container {
    background-color: #f9fafc;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    border: 1px solid #ebeef5;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.02);
}

.search-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.search-form .el-form-item {
    margin-bottom: 16px;
}

.search-form .el-input__inner,
.search-form .el-select__wrapper {
    border-radius: 8px;
    transition: all 0.3s;
}

.search-form .el-input:hover .el-input__inner,
.search-form .el-select:hover .el-input__inner {
    border-color: #409EFF;
}

.action-item {
    margin-left: auto;
}

.query-btn,
.reset-btn {
    width: 90px;
    border-radius: 20px;
    transition: all 0.2s;
}

.query-btn:hover,
.reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.user-table {
    margin-top: 20px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

.user-table :deep(thead) {
    background-color: #f5f7fa;
}

.user-table :deep(th) {
    background-color: #f5f7fa;
    font-weight: 600;
    padding: 14px 0;
}

.user-table :deep(.el-table__row) {
    transition: all 0.3s;
}

.user-table :deep(.el-table__row:hover) {
    transform: translateY(-2px);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    z-index: 1;
    position: relative;
}

.user-avatar {
    cursor: pointer;
    border: 3px solid transparent;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.user-avatar:hover {
    transform: scale(1.2) rotate(5deg);
    border-color: #409EFF;
    box-shadow: 0 6px 16px rgba(64, 158, 255, 0.4);
}

.role-tag,
.state-tag {
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 30px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.tag-icon {
    margin-right: 5px;
}

.action-buttons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.action-btn {
    border-radius: 20px;
    transition: all 0.25s;
}

.action-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.pagination-container {
    margin-top: 20px;
    text-align: right;
    padding: 16px 0;
}

/* 对话框样式 */
:deep(.custom-dialog .el-dialog) {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

:deep(.custom-dialog .el-dialog__header) {
    padding: 20px 25px;
    background: #f9fafc;
    border-bottom: 1px solid #f0f2f5;
    margin-right: 0;
}

:deep(.custom-dialog .el-dialog__title) {
    font-weight: 600;
    color: #303133;
    font-size: 18px;
}

:deep(.custom-dialog .el-dialog__headerbtn) {
    top: 20px;
    right: 20px;
}

:deep(.custom-dialog .el-dialog__body) {
    padding: 25px;
}

:deep(.custom-dialog .el-dialog__footer) {
    padding: 15px 25px;
    border-top: 1px solid #f0f2f5;
}

.dialog-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.dialog-avatar {
    margin-bottom: 20px;
    border: 2px solid #409EFF;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dialog-form {
    width: 100%;
}

.custom-input {
    border-radius: 6px;
}

.custom-select {
    width: 100%;
    border-radius: 6px;
}

.custom-textarea {
    border-radius: 6px;
}

.dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* 角色对话框特定样式 */
.role-dialog-content {
    padding: 10px 0;
}

.user-info {
    display: flex;
    align-items: center;
    margin-bottom: 25px;
    padding: 15px;
    background: #f9fafc;
    border-radius: 8px;
    border: 1px solid #ebeef5;
}

.role-avatar {
    margin-right: 15px;
    border: 2px solid #67c23a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.user-details {
    display: flex;
    flex-direction: column;
}

.username {
    font-size: 18px;
    font-weight: 600;
    color: #303133;
    margin-bottom: 5px;
}

.nickname {
    font-size: 14px;
    color: #606266;
}

.role-dialog-tag {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
}

.role-dialog-tag .el-icon {
    margin-right: 5px;
}

.role-option {
    display: flex;
    align-items: center;
}

.role-option .el-icon {
    margin-right: 8px;
    font-size: 16px;
}

/* 头像预览对话框 */
:deep(.avatar-preview-dialog .el-dialog) {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

:deep(.avatar-preview-dialog .el-dialog__header) {
    display: none;
}

:deep(.avatar-preview-dialog .el-dialog__body) {
    padding: 0;
}

.avatar-preview-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

.preview-image {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 15px;
    border: 3px solid #fff;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.preview-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #303133;
}

.preview-info {
    width: 100%;
    margin-bottom: 15px;
}

.preview-info p {
    display: flex;
    align-items: center;
    margin: 8px 0;
    color: #606266;
}

.preview-info p .el-icon,
.preview-description p .el-icon {
    margin-right: 8px;
    color: #409EFF;
}

.preview-description {
    width: 100%;
    padding: 10px;
    background: #f9fafc;
    border-radius: 8px;
    border: 1px solid #ebeef5;
}

.preview-description p {
    display: flex;
    align-items: flex-start;
    font-style: italic;
    color: #606266;
}

:deep(.el-form-item__label) {
    font-weight: 500;
}

/* 使表格更加美观 */
:deep(.el-table th) {
    background-color: #f5f7fa;
    font-weight: 600;
}

:deep(.el-table--striped .el-table__body tr.el-table__row--striped td) {
    background-color: #fafbfc;
}

:deep(.el-table__row:hover td) {
    background-color: #ecf5ff !important;
}

:deep(.el-pagination) {
    padding: 15px 0;
    font-weight: 500;
}

:deep(.el-pagination button:hover),
:deep(.el-pagination .el-pager li:hover) {
    color: #409EFF;
}

:deep(.el-pagination .el-pager li.active) {
    background-color: #409EFF;
    color: #fff;
}

:deep(.el-form-item.is-required .el-form-item__label::before) {
    color: #f56c6c;
}

:deep(.el-input.is-disabled .el-input__inner) {
    background-color: #f8f9fb;
    color: #606266;
}

.time-cell {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 8px;
    border-radius: 6px;
    transition: all 0.3s;
}

.time-cell:hover {
    background-color: #ecf5ff;
}

.time-cell .el-icon {
    color: #409EFF;
}
</style>